package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 发票信息
 */
@TableName("t_invoice_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.InvoiceInfoMapper")
public class InvoiceInfoDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 交易中心主键id
     */
    @TableField(value = "center_id")
    private Long centerId;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 发票抬头
     */
    @TableField(value = "invoice_title")
    private String invoiceTitle;

    /**
     * 发票号码
     */
    @TableField(value = "invoice_no")
    private String invoiceNo;

    /**
     * 客户名称
     */
    @TableField(value = "customer_name")
    private String customerName;

    /**
     * 客户统一社会信用代码
     */
    @TableField(value = "customer_credit_code")
    private String customerCreditCode;

    /**
     * 客户银行账号
     */
    @TableField(value = "customer_bank_code")
    private String customerBankCode;

    /**
     * 客户开户行名称
     */
    @TableField(value = "customer_opne_bank")
    private String customerOpneBank;

    /**
     * 客户联系地址
     */
    @TableField(value = "customer_address")
    private String customerAddress;

    /**
     * 客户联系电话
     */
    @TableField(value = "customer_phone")
    private String customerPhone;

    /**
     * 客户联系人名称
     */
    @TableField(value = "customer_contact_name")
    private String customerContactName;

    /**
     * 客户联系人电话
     */
    @TableField(value = "customer_contact_tel")
    private String customerContactTel;

    /**
     * 客户email
     */
    @TableField(value = "customer_contact_eamil")
    private String customerContactEamil;

    /**
     * 客户联系地址
     */
    @TableField(value = "customer_contact_address")
    private String customerContactAddress;

    /**
     * 开票金额|保费 分
     */
    @TableField(value = "amount")
    private Long amount;

    /**
     * 开票金额中文大写
     */
    @TableField(value = "amount_of_chinaese")
    private String amountOfChinaese;

    /**
     * 卖方名称
     */
    @TableField(value = "seller_name")
    private String sellerName;

    /**
     * 卖方统一社会信用代码
     */
    @TableField(value = "seller_credit_code")
    private String sellerCreditCode;

    /**
     * 卖方银行账号
     */
    @TableField(value = "seller_bank_code")
    private String sellerBankCode;

    /**
     * 卖方开户行名称
     */
    @TableField(value = "seller_open_bank")
    private String sellerOpenBank;

    /**
     * 卖方联系地址
     */
    @TableField(value = "seller_address")
    private String sellerAddress;

    /**
     * 卖方联系电话
     */
    @TableField(value = "seller_phone")
    private String sellerPhone;

    /**
     * 开票员
     */
    @TableField(value = "handler")
    private String handler;

    /**
     * 发票备注信息
     */
    @TableField(value = "invoice_remark")
    private String invoiceRemark;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 发票内容地址
     */
    @TableField(value = "invoice_img")
    private String invoiceImg;

    /**
     * 发票状态枚举值 0开票中 1已开票 2已开票待下载 3开票失败 4 申请中
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * 订单数
     */
    @TableField(value = "order_count")
    private Integer orderCount;

    @TableField(value = "serial_no")
    private String serialNo;

    @TableField(value = "invoice_code")
    private String invoiceCode;

    /**
     * 发票种类1 电子发票， 2 纸质发票
     */
    @TableField(value = "invoice_category")
    private Integer invoiceCategory;

    /**
     * 开票类型：1:蓝票;2:红票
     */
    @TableField(value = "invoice_type")
    private Integer invoiceType;

    /**
     * 保函类型1-投标保函 2-履约保函 3-工资保函
     */
    @TableField(value = "guarantee_type")
    private Integer guaranteeType;

    /**
     * 申请单位名称
     */
    @TableField(value = "apply_name")
    private String applyName;

    /**
     * 开票主体类型1 企业， 2 个人
     */
    @TableField(value = "invoice_body_type")
    private Integer invoiceBodyType;

    /**
     * pdf发票下载地址
     */
    @TableField(value = "pdf_url")
    private String pdfUrl;

    /**
     * 开票过程备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 查询次数
     */
    @TableField(value = "query_times")
    private Integer queryTimes;

    /**
     * 开票方式0人工录入发票号，1接口开票
     */
    @TableField(value = "invoice_mode")
    private Integer invoiceMode;

    /**
     * 受理订单号若合并开票则逗号隔开
     */
    @TableField(value = "accept_order_nos")
    private String acceptOrderNos;

    /**
     * 发票冲红标识0未冲红1待冲红2冲红中,3冲红成功4冲红失败
     */
    @TableField(value = "invoice_reversal_flag")
    private Integer invoiceReversalFlag;

    /**
     * 冲红发票主键id
     */
    @TableField(value = "invoice_reversal_id")
    private Long invoiceReversalId;

    /**
     * 发票种类：p,普通发票(电票)(默认);c,普通发票(纸票);s,专用发票;e,收购发票(电票);f,收购发票(纸质);r,普通发票(卷式);
     * b,增值税电子专用发票;j,机动车销售统一发票;u,二手车销售统一发票;
     * bs:电子发票(增值税专用发票)-即数电专票(电子),pc:电子发票(普通发票)-即数电普票(电子),
     * es:数电纸质发票(增值税专用发票)-即数电专票(纸质);ec:数电纸质发票(普通发票)-即数电普票(纸质)
     * es:数电纸质发票(增值税专用发票)-即数电专票(纸质);ec:数电纸质发票(普通发票)-即数电普票(纸质)
     */
    @TableField(value = "invoice_line")
    private String invoiceLine;

    /**
     * 通知状态：0-默认；1-通知成功；2：通知失败
     */
    @TableField(value = "notify_status")
    private Integer notifyStatus;

    public InvoiceInfoVo buildVo() {
        return new InvoiceInfoVo(id, centerId, orgId, invoiceTitle, invoiceNo, customerName, customerCreditCode, customerBankCode, customerOpneBank, customerAddress, customerPhone, customerContactName, customerContactTel, customerContactEamil, customerContactAddress, amount, amountOfChinaese, sellerName, sellerCreditCode, sellerBankCode, sellerOpenBank, sellerAddress, sellerPhone, handler, invoiceRemark, gmtCreate, gmtModified, userCreate, userModified, invoiceImg, status, orderCount, serialNo, invoiceCode, invoiceCategory, invoiceType, guaranteeType, applyName, invoiceBodyType, pdfUrl, remark, queryTimes, invoiceMode, acceptOrderNos, invoiceReversalFlag, invoiceReversalId, invoiceLine,notifyStatus);
    }

    public static InvoiceInfoDO of(InvoiceInfoVo vo) {
        return new InvoiceInfoDO(vo.getId(), vo.getCenterId(), vo.getOrgId(), vo.getInvoiceTitle(), vo.getInvoiceNo(), vo.getCustomerName(), vo.getCustomerCreditCode(), vo.getCustomerBankCode(), vo.getCustomerOpneBank(), vo.getCustomerAddress(), vo.getCustomerPhone(), vo.getCustomerContactName(), vo.getCustomerContactTel(), vo.getCustomerContactEamil(), vo.getCustomerContactAddress(), vo.getAmount(), vo.getAmountOfChinaese(), vo.getSellerName(), vo.getSellerCreditCode(), vo.getSellerBankCode(), vo.getSellerOpenBank(), vo.getSellerAddress(), vo.getSellerPhone(), vo.getHandler(), vo.getInvoiceRemark(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getInvoiceImg(), vo.getStatus(), vo.getOrderCount(), vo.getSerialNo(), vo.getInvoiceCode(), vo.getInvoiceCategory(), vo.getInvoiceType(), vo.getGuaranteeType(), vo.getApplyName(), vo.getInvoiceBodyType(), vo.getPdfUrl(), vo.getRemark(), vo.getQueryTimes(), vo.getInvoiceMode(), vo.getAcceptOrderNos(), vo.getInvoiceReversalFlag(), vo.getInvoiceReversalId(), vo.getInvoiceLine(),vo.getNotifyStatus());
    }
}
